package com.chaihu.admin.service.impl.menu;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.chaihu.admin.dao.MenuServiceDao;
import com.chaihu.bean.dto.admin.MenuDto;
import com.chaihu.bean.in.admin.menu.DeleteMenuIn;
import com.chaihu.bean.result.ResponseResult;
import com.chaihu.intf.admin.menu.DeleteMenuService;
import com.chaihu.intf.icommon.BaseService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
public class DeleteMenuServiceImpl extends BaseService<ResponseResult<Void>, DeleteMenuIn> implements DeleteMenuService {
    @Autowired
    private MenuServiceDao menuServiceDao;

    @Override
    public ResponseResult<Void> checkHandle(ResponseResult<Void> responseResult, DeleteMenuIn in) {
        return responseResult;
    }

    @Override
    public ResponseResult<Void> doHandle(ResponseResult<Void> responseResult, DeleteMenuIn in) {
        LambdaQueryWrapper<MenuDto> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(MenuDto::getmId, in.getmId());
        int i = menuServiceDao.delete(queryWrapper);
        return responseResult;
    }

    @Override
    public ResponseResult<Void> respHandle(ResponseResult<Void> responseResult, DeleteMenuIn in) {
        return responseResult;
    }

    @Override
    public ResponseResult<Void> deleteMenu(DeleteMenuIn in) {
        ResponseResult<Void> result = new ResponseResult<>();
        return this.mainHandle(result, in);
    }
}
